#include "Producer.h"
#include "TaskQueue.h"
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <thread>

using std::cout;
using std::endl;

Producer::Producer()
{}

Producer::~Producer()
{}

//真正生产数据的函数
void Producer::produce(TaskQueue &taskQue)
{
    //种随机种子，随机种子与时间相关，时间不一样，后面的随机值
    //就可以不一样
    ::srand(::clock());

    int cnt = 20;
    while(cnt--)
    {
        int number = ::rand() % 100;//产生随机数
        taskQue.push(number);
        cout << "Producer produce number = " << number << endl;
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }
}
